home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v17n02 / turtle.exe / TURTLE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-03  |  2.3 KB  |  91 lines

  1. /*****************************************************************
  2.  *                                                               *
  3.  * TURTLE.C     Main program for TURTLE.C                        *
  4.  *                                                               *
  5.  * Al Williams                                                   *
  6.  *                                                               *
  7.  * TURTLE assumes large model -- see the MAKEFILE for compile    *
  8.  * instructions.                                                 *
  9.  *                                                               *
  10.  *****************************************************************/
  11. #include <stdio.h>
  12. #include <graph.h>
  13. #include <dos.h>
  14. #include <phapi.h>
  15. #include "turtle.h"
  16. #include "xci.h"
  17.  
  18. /* XCI client's application data (see TURTLE.H) */
  19. struct udata appdata;
  20. int installcmds(void);
  21.  
  22. /* XCI startup command -- install commands */
  23. XCICMD startup(int cmd, char far *dummy)
  24.   {
  25.   if (cmd) return;
  26.   if (installcmds())
  27.     {
  28.     printf("Out of memory\n");
  29.     exit(1);
  30.     }
  31.   }
  32.  
  33. /* Reset things before normal exit */
  34. void preexit()
  35.   {
  36.   _setvideomode(_DEFAULTMODE);
  37.   }
  38.  
  39.  
  40. /* MAIN PROGRAM */
  41. main()
  42.   {
  43.   void turtleprompt();
  44. /* register exit routine */
  45.   atexit(preexit);
  46. /* Set some graphics things */
  47.   _setvideomode(_TEXTC80);
  48.   _setactivepage(0);
  49.   _setvisualpage(0);
  50.   appdata.tcolor=appdata.color=15;
  51.   appdata.backcolor=0x003f0000L;   /* blue background */
  52. /* clear screen */
  53.   clearcmd(0,"",&appdata);
  54. /* Print banner */
  55.   printf("TURTLE VGA by Al Williams\n"
  56.          "Type HELP for help\n");
  57.  
  58. /* Take over XCI prompt function */
  59.   xcif_prompt=turtleprompt;
  60.   command("TSAVE.DLL","TURTLE.CMD",0,
  61.           &appdata,(XCICMDP) startup);
  62.   }
  63.  
  64.  
  65.  
  66.  
  67. /* XCI prompt -- if in graphics mode keep input on top line */
  68. void turtleprompt(char *s)
  69.   {
  70.   union REGS r;
  71.   if (appdata.textgraph)
  72.     {
  73. /* don't do newline in graphic mode */
  74.     if (*s=='\n')
  75.       {
  76.       printf(" ");
  77.       return;
  78.       }
  79. /* but do clear the line */
  80.      r.h.ah=2;
  81.      r.h.bh=0;
  82.      r.x.dx=0;
  83.      int86(0x10,&r,&r);
  84.      r.x.ax=0x0a00|' ';
  85.      r.x.bx=appdata.tcolor;
  86.      r.x.cx=40;
  87.      int86(0x10,&r,&r);       /* clear to end of line */
  88.     }
  89.   printf("%s",s);
  90.   }
  91.